/* 
 * Copyright (c) 2012 Christoph Mueller <ruunhb@googlemail.com>
 * 
 * Lqstal is free software: you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Lqstal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef LIQUID_ARRAY_H
#define LIQUID_ARRAY_H

#include "base.h"

struct LqArray;
struct LqPtrArray;

struct LqArray*        lq_array_new(size_t init_capacity, size_t entry_size);

void                    lq_array_free(struct LqArray* array);

size_t                  lq_array_size(struct LqArray* array);
size_t                  lq_array_capacity(struct LqArray* array);


size_t                  lq_array_ensure(struct LqArray* array, size_t min_capacity);
size_t                  lq_array_trim(struct LqArray* array);

void                    lq_array_append(struct LqArray* array, const_pointer data, size_t size);
int             	lq_array_insert(struct LqArray* array, size_t index, const_pointer data, size_t size);
int             	lq_array_remove(struct LqArray* array, size_t index, size_t size);
int			lq_array_replace(struct LqArray* array, size_t index, const_pointer data, size_t size);
void			lq_array_clear(struct LqArray* array);

pointer                 lq_array_clone(struct LqArray* array);
pointer                 lq_array_pointer(struct LqArray* array);
pointer                 lq_array_get(struct LqArray* array, size_t index);
pointer			lq_array_last(struct LqArray* array);


struct LqPtrArray*     	lq_ptr_array_new(size_t init_capacity);
void                    lq_ptr_array_free(struct LqPtrArray* array);

size_t                  lq_ptr_array_size(struct LqPtrArray* array);
size_t                  lq_ptr_array_capacity(struct LqPtrArray* array);

size_t                  lq_ptr_array_ensure(struct LqPtrArray* array, size_t min_capacity);
size_t                  lq_ptr_array_trim(struct LqPtrArray* array);


void                    lq_ptr_array_append(struct LqPtrArray* array, pointer ptr);
int             	lq_ptr_array_insert(struct LqPtrArray* array, size_t index, pointer ptr);
pointer                 lq_ptr_array_remove(struct LqPtrArray* array, size_t index);
pointer			lq_ptr_array_replace(struct LqPtrArray* array, size_t index, pointer ptr);
void			lq_ptr_array_clear(struct LqPtrArray* array, lq_free_funptr fun);

pointer                 lq_ptr_array_get(struct LqPtrArray* array, size_t index);



#endif // LIQUID_ARRAY_H
